/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-24 14:15:58
 * @LastEditTime : 2023-06-18 15:20:19
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\InvestMonthStat.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'
import { InvestListTreeConversion } from '../Common/Conversion'

export const InvestMonthStat = async ({ url, OptionsEvent, Permission }) => {
    const investListUuid = await InvestListTreeConversion()
    let data = {
        type: '投资进度',
        pageSize: 10,
        params: { pageIndex: 1, OrderField: 'yearMonth@desc' },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission?.findIndex(v => v.uuid === '1b34b45c-dcd1-4ce9-b337-8e822acd61e6') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} url={url} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'yearMonth',
                title: '年月',
                valueType: 'Date',
                picker: 'month',
                rules: true,
                hideInSearch: true,
                width: 100,
            },
            {
                dataIndex: 'investListUuid',
                title: '投资清单',
                valueType: 'treeSelect',
                fieldProps: {
                    options: investListUuid,
                    fieldNames: { label: 'tableName', value: 'uuid' },
                },
                width: 200,
            },
            {
                dataIndex: 'amount',
                title: '金额',
                valueType: 'inputNumber',
                rules: true,
                hideInSearch: true,
                width: 200,
            },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === 'a067fb7f-44bc-47cf-9e92-6bbf38636ce9') !== -1 && (
                            <ModDataButton
                                OptionsEvent={OptionsEvent}
                                key="modify"
                                title="修改"
                                url={url}
                                data={record}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === 'a4019107-c9a3-4443-9f8d-ce384ea1adb4') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="delete"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
